package mysql

import (
	"gorm.io/gorm"
)

type User struct {
	gorm.Model
	Name     string `gorm:"type:varchar(20);not null;comment:用户姓名"`
	Mobile   string `gorm:"type:char(11);not null;comment:联系电话"`
	Password string `gorm:"type:char(32);not null;comment:密码"`
}

func (u *User) RegisterUser(user User) error {
	err := DB.Create(&user).Error
	return err
}

func (u *User) UserLogin(mobile string) error {
	err := DB.Where("mobile = ?", mobile).Find(&u).Error
	return err
}
